<?php namespace App\Exceptions;

use Exception;

class OrderException extends Exception
{
    const OrderNotFound        = 0x01;
    const ShopCartNotFound     = 0x02;
    const GoodsNotFound        = 0x03;
    const UserAddressNotFound  = 0x04;
    const UserCouponNotFound   = 0x05;
    const CouponNotUse         = 0x06;
    const OrderAmountNotFull   = 0x07;
    const ExpressNotFound      = 0x08;
    const IntegralNotFull      = 0x09;
    const IntegralNotRecord    = 0x10;
    const AddressNotFound      = 0x11;
    const GoodsStockNotFull    = 0x12;
    const UserInfoNotFound     = 0x13;
    const ActivityNotFound     = 0x14;
    const ActivityExpired      = 0x15;
    const BargainIdNotFount    = 0x16;
    const SystemError          = 0x17;
    const GroupNotFound        = 0x18;
    const GroupAlreadyEnd      = 0x19;
    const GroupNumEnd          = 0x20;
    const GroupNumAlreadyFull  = 0x21;

    public function __construct($code, array $data = [], Exception $previous = null)
    {
        switch ($code) {
            case self::OrderNotFound:
                $message = trans('订单未找到');
                break;
            case self::ShopCartNotFound:
                $message = trans('购物车中未找到该商品');
                break;
            case self::GoodsNotFound:
                $message = trans('商品已下架');
                break;
            case self::UserCouponNotFound:
                $message =trans('没有找到优惠券或者优惠券已被使用');
                break;
            case self::CouponNotUse:
                $message =trans('优惠券已经过期');
                break;
            case self::OrderAmountNotFull:
                $message =trans('未达到满减价格，不可使用优惠券');
                break;
            case self::ExpressNotFound:
                $message =trans('未找到配送的快递公司');
                break;
            case self::IntegralNotFull:
                $message =trans('积分不足');
                break;
            case self::IntegralNotRecord:
                $message =trans('无积分记录存在');
                break;
            case self::AddressNotFound:
                $message =trans('找不到地址');
                break;
            case self::GoodsStockNotFull:
                $message =trans('商品库存不足');
                break;
            case self::UserInfoNotFound:
                $message =trans('未发现用户信息');
                break;
            case self::ActivityNotFound:
                $message =trans('活动未找到');
                break;
            case self::ActivityExpired:
                $message =trans('活动已过期');
                break;
            case self::BargainIdNotFount:
                $message =trans('请传入砍价活动id');
                break;
            case self::SystemError:
                $message =trans('系统错误');
                break;
            case self::GroupNotFound:
                $message =trans('该拼团不存在');
                break;
            case self::GroupAlreadyEnd:
                $message =trans('拼团已过期');
                break;
            case self::GroupNumEnd:
                $message =trans('该拼团已结束');
                break;
            case self::GroupNumAlreadyFull:
                $message =trans('该拼团人数已满');
                break;
            default:
                $message = trans('未知错误');
                break;
        }

        parent::__construct($message, $code, $previous);
    }

}